let t = require;
let  e = module
let  o =  e.exports;
 o.default =  e.exports;

                'use strict';
                console.log("start");
                var _n75,
                    i =
                    (this && this.__extends) ||
                    ((_n75 = function n(t, e) {
                            return (_n75 =
                                Object.setPrototypeOf ||
                                ({
                                        __proto__: []
                                    }
                                    instanceof Array &&
                                    function(t, e) {
                                        t.__proto__ = e;
                                    }) ||
                                function(t, e) {
                                    for (var o in e) {
                                        Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                                    }
                                })(t, e);
                        }),
                        function(t, e) {
                            function o() {
                                this.constructor = t;
                            }
                            _n75(t, e),
                                (t.prototype =
                                    null === e ?
                                    Object.create(e) :
                                    ((o.prototype = e.prototype), new o()));
                        }),
                    r =
                    (this && this.__decorate) ||
                    function(t, e, o, n) {
                        var i,
                            r = arguments.length,
                            a =
                            r < 3 ?
                            e :
                            null === n ?
                            (n = Object.getOwnPropertyDescriptor(e, o)) :
                            n;
                        if (
                            'object' ==
                            (typeof Reflect === 'undefined' ?
                                'undefined' :
                                typeof(Reflect)) &&
                            'function' == typeof Reflect.decorate
                        )
                            a = Reflect.decorate(t, e, o, n);
                        else
                            for (var s = t.length - 1; s >= 0; s--) {
                                (i = t[s]) &&
                                (a = (r < 3 ? i(a) : r > 3 ? i(e, o, a) : i(e, o)) || a);
                            }
                        return r > 3 && a && Object.defineProperty(e, o, a), a;
                    };
                Object.defineProperty(o, '__esModule', {
                        value: !0
                    }),
                    (o.CivilizationMrg = void 0);
                var a = t('AbsInfo'),
                    s = t('CivilizationCfg'),
                    c = t('AbsObject'),
                    l = t('ScienceInfo'),
                    u = t('ScienceCfg'),
                    h = t('BagMrg'),
                    p = t('UmaSdkHelper'),
                    f = cc._decorator,
                    d = f.ccclass,
                    g =
                    (f.property,
                        (function(t) {
                            function e() {
                                return (null !== t && t.apply(this, arguments)) || this;
                            }
                            var o;
                            return (
                                i(e, t),
                                (o = e),
                                Object.defineProperty(e, 'ins', {
                                    get: function get() {
                                        return null == o._ins && (o._ins = new o()), o._ins;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                (e.prototype.init = function(t) {
                                    if (((this._sciences = []), t)) {
                                        for (var e = 0; e < t.sciences.length; e++) {
                                            var o = t.sciences[e];
                                            if (
                                                u.ScienceCfg.ins.getDataByTypeAndLevel(o.type, o.level)
                                            ) {
                                                var n = new l.ScienceInfo(o.type, o.level);
                                                this.addInfo(n);
                                            }
                                        }
                                        this.initCivilization(s.CivilizationCfg.ins.getData(t.id));
                                    } else {
                                        for (e = 0; e < u.ScienceCfg.ins.sciences.length; e++) {
                                            (o = u.ScienceCfg.ins.sciences[e]),
                                            u.ScienceCfg.ins.getDataByTypeAndLevel(
                                                    o.type,
                                                    o.level
                                                ) &&
                                                ((n = new l.ScienceInfo(o.type, o.level)),
                                                    this.addInfo(n));
                                        }
                                        this.initCivilization(s.CivilizationCfg.ins.getData(1));
                                    }
                                    h.BagMrg.ins.addCountEvent(
                                            h.BagMrg.GOLD,
                                            this.onGoldChanged,
                                            this
                                        ),
                                        this.onGoldChanged(
                                            h.BagMrg.ins.getCount(h.BagMrg.GOLD),
                                            h.BagMrg.GOLD
                                        ),
                                        this.calcProgress(),
                                        this.build(),
                                        this.emit(a.InfoEvent.LevelChanged);
                                }),
                                (e.prototype.onGoldChanged = function(t) {
                                    for (var e = !1, o = 0; o < this._sciences.length; o++) {
                                        var n = this._sciences[o];
                                        n.checkRedDotState(t), e || (e = n.redDotState);
                                    }
                                    this._redDotState != e &&
                                        ((this._redDotState = e),
                                            this.emit(a.InfoEvent.RedDotStateChanged),
                                            this._bind && this._bind.setRedDotState(this._redDotState));
                                }),
                                (e.prototype.calcProgress = function() {
                                    for (var t = 0, e = 0; e < this._sciences.length; e++) {
                                        t += this._sciences[e].level;
                                    }
                                    (this.progress = (t - this._lastLevels) / this._needLevels),
                                    this.emit(a.InfoEvent.StateChanged, this.progress);
                                }),
                                (e.prototype.getOpenScienceByType = function(t) {
                                    for (var e = 0; e < s.CivilizationCfg.ins.list.length; e++) {
                                        var o = s.CivilizationCfg.ins.list[e];
                                        if (o.scienceLevels[t - 1] > 0) return o;
                                    }
                                    return null;
                                }),
                                (e.prototype.setBind = function(t) {
                                    (this._bind = t),
                                    this._bind.setRedDotState(this._redDotState);
                                }),
                                Object.defineProperty(e.prototype, 'redDotState', {
                                    get: function get() {
                                        return this._redDotState;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                (e.prototype.addInfo = function(t) {
                                    t.on(
                                            a.InfoEvent.LevelChanged,
                                            this.onLevelChangedHandler,
                                            this
                                        ),
                                        this._sciences.push(t);
                                }),
                                (e.prototype.onLevelChangedHandler = function() {
                                    for (var t = 0, e = 0; e < this.scienceLevels.length; e++) {
                                        var o = this.scienceLevels[e],
                                            n = this._sciences[e];
                                        (0 == o || (o > 0 && n.level >= o)) && t++;
                                    }
                                    t == this.scienceLevels.length && this.upgrade(),
                                        this.calcProgress(),
                                        this.build();
                                }),
                                (e.prototype.upgrade = function() {
                                    var t = s.CivilizationCfg.ins.getData(
                                        this._civilization.id + 1
                                    );
                                    t ? this.initCivilization(t) : (this._isMaxLevel = !0),
                                        this.onGoldChanged(
                                            h.BagMrg.ins.getCount(h.BagMrg.GOLD),
                                            h.BagMrg.GOLD
                                        ),
                                        this.emit(a.InfoEvent.LevelChanged),
                                        p.default.civilizationUpgrade(this.level);
                                }),
                                (e.prototype.initCivilization = function(t) {
                                    var e = s.CivilizationCfg.ins.getData(t.id + 1),
                                        o = s.CivilizationCfg.ins.getData(t.id - 1);
                                    (this._civilization = t),
                                    (this._isMaxLevel = null == e),
                                    (this._needLevels = 0),
                                    (this._lastLevels = 0);
                                    for (var n = 0; n < this._sciences.length; n++) {
                                        var i = this._sciences[n];
                                        (i.maxLevel = t.scienceLevels[i.type - 1]),
                                        (this._needLevels += i.maxLevel);
                                    }
                                    if (o)
                                        for (n = 0; n < o.scienceLevels.length; n++) {
                                            this._lastLevels += o.scienceLevels[n];
                                        }
                                    this._needLevels -= this._lastLevels;
                                }),
                                (e.prototype.getData = function() {
                                    var t = {};
                                    t.id = this._civilization.id;
                                    for (var e = [], o = 0; o < this._sciences.length; o++) {
                                        var n = this._sciences[o];
                                        e.push({
                                            type: n.type,
                                            level: n.level
                                        });
                                    }
                                    return (t.sciences = e), t;
                                }),
                                (e.prototype.newDay = function() {}),
                                (e.prototype.build = function() {
                                    (this._hp = 0),
                                    (this._atk = 0),
                                    (this._def = 0),
                                    (this._crit = 0),
                                    (this._solid = 0),
                                    (this._hpPer = 0),
                                    (this._atkPer = 0),
                                    (this._defPer = 0);
                                    for (var t = 0; t < this._sciences.length; t++) {
                                        var e = this._sciences[t];
                                        (this._hp += e.hp),
                                        (this._atk += e.atk),
                                        (this._def += e.def),
                                        (this._crit += e.crit),
                                        (this._solid += e.solid),
                                        (this._hpPer += e.hpPer),
                                        (this._atkPer += e.atkPer),
                                        (this._defPer += e.def);
                                    }
                                    this.emit(a.InfoEvent.PropertyChanged);
                                }),
                                Object.defineProperty(e.prototype, 'data', {
                                    get: function get() {
                                        return this._civilization;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'id', {
                                    get: function get() {
                                        return this._civilization.id;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'level', {
                                    get: function get() {
                                        return this._civilization.level;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'name', {
                                    get: function get() {
                                        return this._civilization.name;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'icon', {
                                    get: function get() {
                                        return this._civilization.icon;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'itemLevels', {
                                    get: function get() {
                                        return this._civilization.itemLevels;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'itemRands', {
                                    get: function get() {
                                        return this._civilization.itemRands;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'scienceLevels', {
                                    get: function get() {
                                        return this._civilization.scienceLevels;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'sciences', {
                                    get: function get() {
                                        return this._sciences;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'isMaxLevel', {
                                    get: function get() {
                                        return this._isMaxLevel;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'hp', {
                                    get: function get() {
                                        return this._hp;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'atk', {
                                    get: function get() {
                                        return this._atk;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'def', {
                                    get: function get() {
                                        return this._def;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'crit', {
                                    get: function get() {
                                        return this._crit;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'solid', {
                                    get: function get() {
                                        return this._solid;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'hpPer', {
                                    get: function get() {
                                        return this._hpPer;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'atkPer', {
                                    get: function get() {
                                        return this._atkPer;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                Object.defineProperty(e.prototype, 'defPer', {
                                    get: function get() {
                                        return this._defPer;
                                    },
                                    enumerable: !1,
                                    configurable: !0
                                }),
                                (o = r([d('CivilizationMrg')], e))
                            );
                        })(c.AbsObject));
                (o.CivilizationMrg = g), console.log("end");
            module.exports =  e.exports;